//
//  CheckNewsController.m
//  PosApp
//
//  Created by 刘萍 on 2018/9/11.
//  Copyright © 2018年 李英新. All rights reserved.
//

#import "CheckNewsController.h"
#import "CheckNewsHeadView.h"
#import "CheckNewsViewCell.h"

#import "JFDuiHuanController.h"
#import "HalfYearController.h"

@interface CheckNewsController ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *NewsTable;
@property (weak, nonatomic) IBOutlet UIButton *HuaBtn;

@property (weak, nonatomic) IBOutlet UIView *BackView;
@property (weak, nonatomic) IBOutlet UIView *BackView01;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *BackView01H;

@property (weak, nonatomic) IBOutlet UILabel *JFLabel;
@property (weak, nonatomic) IBOutlet UILabel *XJLabel;



@end

@implementation CheckNewsController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"招商银行6688";
    
    if (KIsShow) {
        NSLog(@"111");
        self.BackView.hidden = YES;
        self.BackView01.hidden = YES;
    }else{
        NSLog(@"222");
        self.BackView.hidden = NO;
        self.BackView01.hidden = NO;
    }
    
    self.NewsTable.delegate = self;
    self.NewsTable.dataSource = self;
    self.NewsTable.rowHeight = 50;
    self.NewsTable.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.NewsTable registerNib:[UINib nibWithNibName:@"CheckNewsViewCell" bundle:nil] forCellReuseIdentifier:@"cell"];
    
    self.NewsTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [self UpLoadDataOfCheckNewsController];
    }];
    
    if (KIsiPhoneX) {
        self.BackView01H.constant = 250;
    }else{
        self.BackView01H.constant = 210;
    }
    
    UISwipeGestureRecognizer * leftTap =[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipes:)];
    
    leftTap.direction=UISwipeGestureRecognizerDirectionLeft;
    
    [self.HuaBtn addGestureRecognizer:leftTap];
   
    UIVisualEffect *blurEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight];
    UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:blurEffect];
    
    visualEffectView.alpha = 0.9;
    visualEffectView.frame = CGRectMake(0, 0, KScreenW, KScreenH);
    [self.BackView addSubview:visualEffectView];
    
}

- (void)handleSwipes:(UISwipeGestureRecognizer *)tap{
    HalfYearController * HYC = [[HalfYearController alloc] init];
    [self.navigationController pushViewController:HYC animated:YES];
}



- (IBAction)ClickOnBtnToUpLoadData:(id)sender {
    NSLog(@"刷新数据");
    [self.NewsTable.mj_header beginRefreshing];
}

- (void)UpLoadDataOfCheckNewsController {
    [self.NewsTable.mj_header endRefreshing];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CheckNewsViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {
        cell = [[CheckNewsViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    }
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 260;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    CheckNewsHeadView * headV = [[NSBundle mainBundle] loadNibNamed:@"CheckNewsHeadView" owner:self options:nil][0];
    return headV;
}
- (IBAction)ClickOnBtnToPopController:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}
- (IBAction)ClickOnBtnToMoreNews:(id)sender {
}
- (IBAction)ClickOnBtnOfTXbtn:(id)sender {
    
}
- (IBAction)ClickOnBtnToHiddenBackView:(id)sender {
    SetIsShow(YES);
    self.BackView.hidden = YES;
    self.BackView01.hidden = YES;
    JFDuiHuanController * duiC = [[JFDuiHuanController alloc] init];
    [self.navigationController pushViewController:duiC animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
